package queuearr;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static int front = -1, rear = -1, max = 20;
    public static int val;
    public static char ch;
    public static int queue[] = new int[max];

    public static void main(String[] args) throws IOException {
        String strM;
        int M = 0;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (rear < max - 1 && M != 3){
            System.out.println("[1]存入一个数值 [2]取出一个数值 [3]结束：");
            strM = reader.readLine();
            M = Integer.parseInt(strM);
            switch (M){
                case 1:
                    System.out.println("\n[请输入数值：]");
                    strM = reader.readLine();
                    val = Integer.parseInt(strM);
                    rear++;
                    queue[rear] = val;
                    break;
                case 2:
                    if (rear > front){
                        front++;
                        System.out.println("\n[取出的数值]:[" + queue[front] + "]" + "\n");
                        queue[rear] = 0;
                    }else {
                        System.out.println("\n[队列已经空了]\n");
                        break;
                    }
                    break;
                default:
                    System.out.println("\n");
                    break;
            }
        }
        if (rear == max - 1){
            System.out.println("\n[队列已经满了]\n");
        }
        System.out.println("\n[目前的队列数据：]\n");
        if (front >= rear){
            System.out.println("没有\n");
            System.out.println("[队列已经空了]\n");
    }else {
            while (rear > front){
                front++;
                System.out.println("[" + queue[front] + "]");
            }
            System.out.println("\n");
        }

    }
}






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































